Page({
  data: {
    nickName: '',
    avatar: '',
  },
  onShow() {
    console.log('[ my onShow ] >')

    this.getUserInfo()
  },

  async getUserInfo() {
    const { data: userInfo } = await wx.http({ url: '/userInfo' })
    this.setData({
      nickName: userInfo.nickName,
      avatar: userInfo.avatar,
    })
  },

  goLogin() {
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },

  logout() {
    // 删全局数据
    getApp().global.token = null
    // 删本地存储
    wx.removeStorageSync('token')
    // 跳登录页
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },
})
